
from django.shortcuts import render,redirect
from polls.models import Imgs
from comment.models import Comment


def updata_comment(requset):
    user = requset.user
    text = requset.POST.get('text', '')
    # 获取传过来的id
    id = int(requset.POST.get('comment_id', ''))
    # 实例化模型类
    comment = Comment()
    # 将名字传给模型
    comment.user = user
    # 将输入类容传给模型
    comment.text = text
    # 将外键与Comment模型关联
    comment.post =Imgs.objects.get(pk=id)
    # 保存到数据库
    comment.save()
    # 拿到当前页面的路径再刷新
    referer = requset.META.get('HTTP_REFERER')
    return redirect(referer)







